﻿using System;
using Windows.UI.Xaml.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TR1app.Common
{
    /// <summary>
    /// Value converter that translates true to false and vice versa.
    /// </summary>
    public sealed class AuthorNameConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            // value is the data from the source object.
            string  aboutAuthor = (string)value;
            if (aboutAuthor.Length == 0)
                return aboutAuthor;
            String [] values = aboutAuthor.Split(new string[] { "\r\n" }, System.StringSplitOptions.RemoveEmptyEntries);
            string option = (string)parameter;
            // Return the value to pass to the target.
            if (option == "name")
            { return values[0].Trim(); }
            else
            { return values[1].Trim(); }       
        }

        public object ConvertBack(object value, Type targetType, object parameter, string language)
        {
            throw new NotImplementedException();
        }
    }
}
